<template>
  <div>
    <div>
      <!-- (重要)遇到复选框, v-model的变量值
              非数组 - 关联的是复选框的checked属性
              数组   - 关联的是复选框的value属性
            -->
      <span>爱好:</span>
      <span v-for="(item,index) in list" :key="index">
        <input type="checkbox" :value="item" v-model="hobby">
        <span>{{item}}</span>
      </span>
    </div>
    <ul>
      <li v-for="item in hobby" :key="item">
        {{ item }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 爱好数据
      list: ["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],
      hobby: [],
    };
  },
};
</script>

<style scoped>
</style>
